package com.asset.admin.system.tradingtype.biz.impl;

import com.asset.admin.system.tradingtype.biz.ITradingTypeBiz;
import com.asset.admin.dao.entity.TradingTypeEntity;
import com.asset.admin.dao.mapper.ITradingTypeMapper;
import com.asset.admin.system.tradingtype.form.TradingTypeForm;
import com.asset.admin.system.tradingtype.form.TradingTypeQueryForm;
import com.asset.common.helper.CurrentUserHelper;
import com.asset.common.utils.DateUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 交易类型biz实现
 * </p>
 *
 * @author 牧之
 * @date 2024/2/7 16:08
 */
@Service
public class TradingTypeBizImpl implements ITradingTypeBiz {

    @Resource
    private ITradingTypeMapper mapper;

    @Override
    public void create(TradingTypeForm form) {
        //参数校验
        Long currentUserId = CurrentUserHelper.getCurrentUserId();

        TradingTypeEntity entity = TradingTypeForm.convertForm2Entity(form);
        entity.setCreator(currentUserId);
        entity.setUpdateTime(DateUtil.getCurrentTime());
        mapper.create(entity);
    }

    @Override
    public void deleteById(Long id) {
        mapper.deleteById(id);
    }

    @Override
    public void update(TradingTypeEntity entity) {
        mapper.update(entity);
    }

    @Override
    public TradingTypeForm getById(Long id) {
        TradingTypeEntity entity = mapper.getById(id);
        return TradingTypeForm.convertEntity2Form(entity,null);
    }

    @Override
    public List<TradingTypeEntity> getListByQuery(TradingTypeQueryForm queryForm) {
        return mapper.getListByQuery(queryForm);
    }

    @Override
    public int getCount(TradingTypeQueryForm queryForm) {
        return mapper.getCount(queryForm);
    }
}
